package com.wavehi;

/**
 * @Author WaveHi
 * @Date 28/10/2021 下午 9:57
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description
 */
import com.wavehi.pojo.Person;
import com.wavehi.pojo.Pet;
import com.wavehi.pojo.User;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//@RestController
//@EnableAutoConfiguration
//public class MyApplication {
//
//    @RequestMapping("/")
//    String home() {
//        return "Hello World!";
//    }
//
//    public static void main(String[] args) {
//        SpringApplication.run(MyApplication.class, args);
//    }
//
//}
@SpringBootApplication
public class MyApplication {

    public static void main(String[] args) {
        //获取IOC容器
        ConfigurableApplicationContext configurableApplicationContext = SpringApplication.run(MyApplication.class);
        //获取组件名
        String[] names = configurableApplicationContext.getBeanDefinitionNames();
        for (String name : names) {
            System.out.println(name);
        }

        //
        System.out.println(configurableApplicationContext.getBean("getPerson", Person.class));
        System.out.println(configurableApplicationContext.getBean("getPet", Pet.class));
        System.out.println(configurableApplicationContext.getBean("getUser", User.class));
        System.out.println(configurableApplicationContext.getBean("userTom", User.class));
    }
}



